{include="header"}

<div class="container-fluid" style="margin-top: 10px; margin-bottom: 10px;">
   <div class="row">
      <div class="col-sm-2">
         <div class="btn-group">
            <a class="btn btn-sm btn-default" href="{$fsc->url()}" title="Recargar la página">
               <span class="glyphicon glyphicon-refresh"></span>
            </a>
            {if condition="$fsc->page->is_default()"}
            <a class="btn btn-sm btn-default active" href="{$fsc->url()}&amp;default_page=FALSE" title="desmarcar como página de inicio">
               <span class="glyphicon glyphicon-home"></span>
            </a>
            {else}
            <a class="btn btn-sm btn-default" href="{$fsc->url()}&amp;default_page=TRUE" title="marcar como página de inicio">
               <span class="glyphicon glyphicon-home"></span>
            </a>
            {/if}
         </div>
      </div>
      <div class="col-sm-7 text-center">
         <h3 style="margin-top: 0px;">{$fsc->page->title}</h3>
      </div>
      <div class="col-sm-3 text-right">
         <a class="btn btn-sm btn-danger" href="{$fsc->url()}&clean_cache=TRUE">
            <span class="glyphicon glyphicon-trash"></span> &nbsp; Limpiar la cache
         </a>
      </div>
   </div>
</div>

<div role="tabpanel">
   <ul class="nav nav-tabs" role="tablist">
      <li role="presentation" class="active">
         <a href="#home" aria-controls="home" role="tab" data-toggle="tab">
            <span class="glyphicon glyphicon-dashboard" aria-hidden="true"></span>
         </a>
      </li>
      <li role="presentation">
         <a href="#history" aria-controls="history" role="tab" data-toggle="tab">Historial</a>
      </li>
      <li role="presentation">
         <a href="#tablas" aria-controls="tablas" role="tab" data-toggle="tab">Tablas</a>
      </li>
      <li role="presentation">
         <a href="#bloqueos" aria-controls="bloqueos" role="tab" data-toggle="tab">Bloqueos</a>
      </li>
   </ul>
   <div class="tab-content">
      <div role="tabpanel" class="tab-pane active" id="home">
         <div class="table-responsive">
            <table class="table table-hover">
               <thead>
                  <tr>
                     <th class="text-left">FacturaScripts</th>
                     <th class="text-center">PHP</th>
                     <th class="text-center">Base de datos</th>
                     <th class="text-center">Motor de base de datos</th>
                     <th class="text-right">Memcache</th>
                  </tr>
               </thead>
               <tr>
                  <td>{$fsc->version()}</td>
                  <td class="text-center">{$fsc->php_version()}</td>
                  <td class="text-center">{$fsc->fs_db_name()}</td>
                  <td class="text-center">{$fsc->fs_db_version()}</td>
                  <td class="text-right">{$fsc->cache_version()}</td>
               </tr>
            </table>
         </div>
         <div class="panel-group" id="accordion" style="margin: 10px;">
            <div class="panel panel-default">
               <div class="panel-heading">
                  <h3 class="panel-title">
                     <a data-toggle="collapse" data-parent="#accordion" href="#collapse_so">Sistema operativo</a>
                  </h3>
               </div>
               <div id="collapse_so" class="panel-collapse collapse in">
                  <div class="panel-body">{$fsc->uname()}</div>
                  {if condition="$fsc->linux()"}
                  <div class="panel-footer">
                     <b>Uptime:</b> {$fsc->sys_uptime()}
                  </div>
                  {/if}
               </div>
            </div>

            {if condition="$fsc->linux()"}
            <div class="panel panel-default">
               <div class="panel-heading">
                  <h3 class="panel-title">
                     <a data-toggle="collapse" data-parent="#accordion" href="#collapse_mem">Memoria</a>
                  </h3>
               </div>
               <div id="collapse_mem" class="panel-collapse collapse">
                  <div class="panel-body"><pre>{$fsc->sys_free()}</pre></div>
               </div>
            </div>

            <div class="panel panel-default">
               <div class="panel-heading">
                  <h3 class="panel-title">
                     <a data-toggle="collapse" data-parent="#accordion" href="#collapse_dd">Disco duro</a>
                  </h3>
               </div>
               <div id="collapse_dd" class="panel-collapse collapse">
                  <div class="panel-body"><pre>{$fsc->sys_df()}</pre></div>
               </div>
            </div>
            {/if}
         </div>
      </div>
      <div role="tabpanel" class="tab-pane" id="history">
         <div class="table-responsive">
            <table class="table table-hover">
               <thead>
                  <tr>
                     <th class="text-left">Usuario</th>
                     <th class="text-left">Detalle</th>
                     <th class="text-left">IP</th>
                     <th class="text-right">Fecha</th>
                  </tr>
               </thead>
               {loop="$fsc->get_fs_log()"}
               <tr{if condition="$value->alerta"} class="bg-danger"{/if}>
                  <td><a href="index.php?page=admin_user&snick={$value->usuario}">{$value->usuario}</a></td>
                  <td>{$value->detalle}</td>
                  <td>{$value->ip}</td>
                  <td class="text-right">{$value->fecha}</td>
               </tr>
               {/loop}
            </table>
         </div>
      </div>
      <div role="tabpanel" class="tab-pane" id="tablas">
         <div class="container-fluid" style="margin-top: 10px;">
            <div class="row">
               {loop="$fsc->get_db_tables()"}
               <div class="col-md-4">{$value.name}</div>
               {/loop}
            </div>
         </div>
      </div>
      <div role="tabpanel" class="tab-pane" id="bloqueos">
         <div class="table-responsive">
            <table class="table table-hover">
               <thead>
                  <tr>
                     <th class="text-left">Base de datos</th>
                     <th class="text-left">relname</th>
                     <th class="text-left">relation</th>
                     <th class="text-left">transaction ID</th>
                     <th class="text-left">PID</th>
                     <th class="text-left">modo</th>
                     <th class="text-left">granted</th>
                  </tr>
               </thead>
               {loop="$fsc->get_locks()"}
               <tr>
                  <td>{$value.database}</td>
                  <td>{$value.relname}</td>
                  <td>{$value.relation}</td>
                  <td>{$value.transactionid}</td>
                  <td>{$value.pid}</td>
                  <td>{$value.mode}</td>
                  <td>{$value.granted}</td>
               </tr>
               {else}
               <tr class="bg-warning">
                  <td colspan="7">Ningún bloqueo detectado.</td>
               </tr>
               {/loop}
            </table>
         </div>
      </div>
   </div>
</div>

{include="footer"}